package com.haizhi.crm.sys.auth.dao;

import com.haizhi.crm.sys.auth.model.RoleResourcePermissionDo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * Created by yangyijun on 2018/5/10.
 */
@Repository
public interface RoleResourcePermissionDao extends JpaRepository<RoleResourcePermissionDo, Long> {
    @Query(value = "select count(1) from RoleResourcePermissionDo where roleId in :roleIds" )
    Integer findByRoleIds(@Param("roleIds" ) Long[] roleIds);

    @Modifying
    @Query(value = "delete from RoleResourcePermissionDo where roleId in :roleIds" )
    void deleteByRoleIds(@Param("roleIds" ) Long[] roleIds);

    void deleteByRoleId(@Param("roleId" ) Long roleId);
}
